package table;

import javax.swing.*;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;

public class Dao {
    String url = "jdbc:oracle:thin:@localhost:1521:XE";
    String userName = "new";
    String userPwd = "126875";

    public List<Object[]> selectAll() {
        List<Object[]> ls = new ArrayList<Object[]>();
        // 省略连接数据库和获取数据

        Object[][] result = new Object[100][8];

        try {
            String sql = "select * from SELL order by shuliang DESC ";
            Connection conn = DriverManager.getConnection(url, userName, userPwd);
            PreparedStatement pstm = conn.prepareStatement(sql);
            ResultSet rs = pstm.executeQuery();
            int i = 0;
            while(rs.next()){
                for(int j=0;j<8;j++){
                result[i][j]=rs.getString(j+1);
            }ls.add(result[i]);
                i=i+1;
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return ls;

        }
    }